package com.zhonghui.wms.controller;

import com.zhonghui.common.annotation.Log;
import com.zhonghui.common.core.controller.BaseController;
import com.zhonghui.common.core.page.TableDataInfo;
import com.zhonghui.common.enums.BusinessType;
import com.zhonghui.common.utils.poi.ExcelUtil;
import com.zhonghui.response.BaseResult;
import com.zhonghui.wms.domain.WmsWarehousingApplicationDetails;
import com.zhonghui.wms.service.IWmsWarehousingApplicationDetailsService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 智能仓储WMS-入库申请明细Controller
 *
 * @author zhonghui
 * @date 2023-08-14
 */
@Api(tags="智能仓储WMS-入库申请明细")
@RestController
@RequestMapping("/wms/warehousingApplicationDetails")
public class WmsWarehousingApplicationDetailsController extends BaseController {

    @Autowired
    private IWmsWarehousingApplicationDetailsService wmsWarehousingApplicationDetailsService;

    /**
     * 查询智能仓储WMS-入库申请明细列表
     */
    @ApiOperation("查询智能仓储WMS-入库申请明细列表")
    @GetMapping("/list")
    public TableDataInfo<List<WmsWarehousingApplicationDetails>> list(WmsWarehousingApplicationDetails wmsWarehousingApplicationDetails)
    {
        startPage();
        List<WmsWarehousingApplicationDetails> list = wmsWarehousingApplicationDetailsService.selectWmsWarehousingApplicationDetailsList(wmsWarehousingApplicationDetails);
        return getDataTable(list);
    }

    /**
     * 导出智能仓储WMS-入库申请明细列表
     */
    @ApiOperation("导出智能仓储WMS-入库申请明细列表")
    @Log(title = "智能仓储WMS-入库申请明细", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, WmsWarehousingApplicationDetails wmsWarehousingApplicationDetails)
    {
        List<WmsWarehousingApplicationDetails> list = wmsWarehousingApplicationDetailsService.selectWmsWarehousingApplicationDetailsList(wmsWarehousingApplicationDetails);
        ExcelUtil<WmsWarehousingApplicationDetails> util = new ExcelUtil<WmsWarehousingApplicationDetails>(WmsWarehousingApplicationDetails.class);
        util.exportExcel(response, list, "智能仓储WMS-入库申请明细数据");
    }

    /**
     * 获取智能仓储WMS-入库申请明细详细信息
     */
    @ApiOperation("获取智能仓储WMS-入库申请明细详细信息")
    @GetMapping(value = "/{id}")
    public BaseResult<WmsWarehousingApplicationDetails> getInfo(@PathVariable("id") Long id)
    {
        return BaseResult.success(wmsWarehousingApplicationDetailsService.selectWmsWarehousingApplicationDetailsById(id));
    }

    /**
     * 新增智能仓储WMS-入库申请明细
     */
    @ApiOperation("新增智能仓储WMS-入库申请明细")
    @Log(title = "智能仓储WMS-入库申请明细", businessType = BusinessType.INSERT)
    @PostMapping
    public BaseResult<Integer> add(@RequestBody WmsWarehousingApplicationDetails wmsWarehousingApplicationDetails)
    {
        return BaseResult.success(wmsWarehousingApplicationDetailsService.insertWmsWarehousingApplicationDetails(wmsWarehousingApplicationDetails));
    }

    /**
     * 修改智能仓储WMS-入库申请明细
     */
    @ApiOperation("修改智能仓储WMS-入库申请明细")
    @Log(title = "智能仓储WMS-入库申请明细", businessType = BusinessType.UPDATE)
    @PutMapping
    public BaseResult<Integer> edit(@RequestBody WmsWarehousingApplicationDetails wmsWarehousingApplicationDetails)
    {
        return BaseResult.success(wmsWarehousingApplicationDetailsService.updateWmsWarehousingApplicationDetails(wmsWarehousingApplicationDetails));
    }

    /**
     * 删除智能仓储WMS-入库申请明细
     */
    @ApiOperation("删除智能仓储WMS-入库申请明细")
    @Log(title = "智能仓储WMS-入库申请明细", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public BaseResult<Integer> remove(@PathVariable Long[] ids)
    {
        return BaseResult.success(wmsWarehousingApplicationDetailsService.deleteWmsWarehousingApplicationDetailsByIds(ids));
    }
}
